<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>我的jsp项目</title>
    <script type="text/javascript" src="static/js/jquery.js"></script>
    <style type="text/css">
    	span{
    		color:red;
    	}
    </style>
  </head>
  
  <body>
  	<h3>系统登录</h3>
  	<c:choose>
  		<c:when test="${param.code == '10001'}">
  			<div style="color:red">用户名或密码错误</div>
  		</c:when>
  		<c:when test="${param.code == '10002'}">
  			<div style="color:red">请先登录</div>
  		</c:when>
  		<c:when test="${param.code == '10003'}">
  			<div style="color:red">验证码错误</div>
  		</c:when>
  	</c:choose>
  
  	<form action="login.jspx" method="post" id="myform">
  		UserName: <input type="text" name="username"/><span id="name_error"></span> <br/>
  		Password: <input type="password" name="password"/><span id="pwd_error"></span> <br/>
  		验证码：<input type="text" name="captcha"/>
  		<a href="javascript:;" id="changeValidate"><img id="change" src="jcaptcha.jpg"/></a>
  		<input type="button" value="Login" id="btn"/>
  	</form>
  	
  	<img alt="" src="static/img/glyphicons-halflings.png">
  	<script type="text/javascript">
  		$(document).ready(function(){
  			$("#changeValidate").click(function(){
  				$("#change").attr("src","jcaptcha.jpg");
  			});
  		
  			$("#btn").click(function(){
  				var name = $("input[name='username']").val();
  				var pwd = $("input[name='password']").val();
  				if(name.trim() == "") {
  					$("#name_error").html("请输入用户名");
  					return;
  				}
  				if(pwd == "") {
  					$("#pwd_error").html("请输入密码");
  					return;
  				}
  				$("#myform").submit();
  				
  			});
  			
  		});
  	
  	</script>
  </body>
</html>
